﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Translator
{
    class Program
    {
        static void Main(string[] args)
        {
            bool bRunning = true;
            while (bRunning)
            {
                string inputString = Console.ReadLine();
                inputString = inputString.Trim();
                inputString = inputString.ToLower();
                switch (inputString)
                {
                    case "help":
                        Console.WriteLine("Translator input format:");
                        Console.WriteLine("Hex String [space] target type[Enter]");
                        Console.WriteLine("Quit for exit");
                        break;
                    case "quit":
                        bRunning = false;
                        break;

                    default:
                        int nidx = inputString.LastIndexOf(' ');
                        if (nidx > 0)
                        {
                            string target = inputString.Substring(nidx + 1);
                            if (Translator.IsValidTarget(target))
                            {
                                Console.WriteLine(Translator.Translate(
                                    inputString.Substring(0, nidx), target));
                                break;
                            }
                        }
                        Console.WriteLine("Wrong input");
                        break;

                }
            }
        }
    }
}
